package lcspm.lib;

import java.io.File;
import java.util.Set;
import net.minecraftforge.common.ConfigCategory;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.Property;

public class ConfigHandler
{
  static Configuration config;

  public static void SetConfig(String name, String value, int dim, String world, String player, boolean isPublic)
  {
    config.load();
    config.get(name, "world", world);
    config.get(name, "player", player);
    config.get(name, "coor", value);
    config.get(name, "ispublic", isPublic);
    config.get(name, "dim", dim);
    config.save();
  }

  public static String getConfig(String catName)
  {
    ConfigCategory cc = config.getCategory(catName);

    String catKey = cc.get("coor").getString();

    return catKey;
  }

  public static ConfigCategory getCategory(String catName)
  {
    return config.getCategory(catName);
  }

  public static Set<String> getCategories() {
    return config.getCategoryNames();
  }

  public static boolean HasCategory(String name) {
    return config.hasCategory(name);
  }

  public static void delCategory(String name) {
    ConfigCategory cc = config.getCategory(name);
    config.load();
    config.removeCategory(cc);
    config.save();
  }

  public static void init(File configFile)
  {
    config = new Configuration(configFile);
    config.load();
    config.save();
  }
}